package com.asset.dispoal.file.agreementCaseData;

import com.asset.dispoal.file.agreementCaseData.api.AgreementCaseDataService;
import com.asset.dispoal.file.agreementCaseData.dto.AddressGetCodeRequest;
import com.asset.dispoal.file.agreementCaseData.dto.AgreementExportRequest;
import com.asset.dispoal.file.agreementCaseData.dto.ExportEvidenceDataRequest;
import com.asset.dispoal.file.agreementCaseData.dto.ImportAbolishCaseRequest;
import com.asset.dispoal.file.agreementCaseData.dto.ImportRevertCaseRequest;
import com.asset.dispoal.file.agreementCaseData.dto.ImportSmsStateRequest;
import com.asset.dispoal.file.agreementCaseData.dto.RefreshIdCardRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import tech.mhuang.pacebox.springboot.protocol.Result;

import javax.servlet.http.HttpServletResponse;

/**
 * @author qr
 * @date 2022/4/6$
 */
@RestController
@Api(value = "合同案件数据", tags = "合同案件数据")
@RequestMapping("file/data")
public class AgreementCaseDataController {

    @Autowired
    AgreementCaseDataService agreementCaseDataService;

    @PostMapping("importData")
    @ApiOperation(value = "上传excel", notes = "上传excel")
    private Result<String> importData(MultipartFile multipartFile) {
        return agreementCaseDataService.importData(multipartFile);
    }


    @ApiOperation(value = "上传路径", notes = "上传路径")
    @GetMapping(value = "/uploadPath")
    public Result uploadExcel(@ApiParam("文件路径") @RequestParam("filepath") String filepath, String assetInstBatchId) {
        agreementCaseDataService.uploadExcel(filepath, assetInstBatchId);
        return Result.ok();
    }

    @ApiOperation(value = "导入废案", notes = "导入废案")
    @PostMapping(value = "importAbolishCase")
    public Result importAbolishCase(ImportAbolishCaseRequest request) {
        return agreementCaseDataService.importAbolishCase(request);
    }

    @ApiOperation(value = "导入恢复", notes = "导入恢复")
    @PostMapping(value = "importRevertCase")
    public Result importRevert(ImportRevertCaseRequest request) {
        return agreementCaseDataService.importRevertCase(request);
    }

    @ApiOperation(value = "刷新身份证日期", notes = "刷新身份证日期")
    @PostMapping(value = "refreshIdCard")
    public Result refreshIdCard(RefreshIdCardRequest request) {
        return agreementCaseDataService.refreshIdCard(request);
    }

    @ApiOperation(value = "导入身份证日期", notes = "导入身份证日期")
    @PostMapping(value = "importIdCardDate")
    public Result importIdCardDate(MultipartFile file) {
        return agreementCaseDataService.importIdCardDate(file);
    }

    @ApiOperation(value = "导出未匹配上身份证日期", notes = "导出身份证日期未匹配上的")
    @GetMapping("/exportNoIdCardRefreshData")
    public Result exportNoIdCardRefreshData(String id) {
        return agreementCaseDataService.exportNoIdCardRefreshData(id);
    }

    @ApiOperation(value = "案件户籍地址获取code码", notes = "案件户籍地址获取code码")
    @GetMapping("/caseAddressGetCode")
    public Result caseAddressGetCode(AddressGetCodeRequest request) {
        return agreementCaseDataService.caseAddressGetCode(request);
    }

    @ApiOperation(value = "短信状态导入", notes = "短信状态导入")
    @PostMapping(value = "importSmsState")
    public Result importSmsState(ImportSmsStateRequest request) {
        return agreementCaseDataService.importSmsState(request);
    }

    @GetMapping(value = "/exportExcel")
    @ApiOperation(value = "合同信息导出", notes = "合同信息导出")
    public void exportExcel(HttpServletResponse response, AgreementExportRequest request) {
        agreementCaseDataService.exportExcel(response, request);
    }

    @GetMapping(value = "/exportCaseExcel")
    @ApiOperation(value = "合同信息导出", notes = "合同信息导出")
    public void exportCaseExcel(HttpServletResponse response, AgreementExportRequest request) {
        agreementCaseDataService.exportCaseExcel(response, request);
    }

    @GetMapping(value = "/exportExcelTemplate")
    @ApiOperation(value = "合同导入模板导出", notes = "合同导入模板导出")
    public void exportExcelTemplate(HttpServletResponse response, String assetInstBatchId) {
        agreementCaseDataService.exportExcelTemplate(response, assetInstBatchId);
    }

    @GetMapping(value = "/exportEvidenceData")
    @ApiOperation(value = "证据查阅导出", notes = "证据查阅导出")
    public void exportEvidenceData(HttpServletResponse response, ExportEvidenceDataRequest request) {
        agreementCaseDataService.exportEvidenceData(response, request);
    }
}